Skip to content

#9191 mass energy eqivalence #9217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 31 commits into from
Closed

#9191 mass energy eqivalence #9217

wants to merge 31 commits into from

Conversation

mhsuhail00
Copy link

@mhsuhail00 mhsuhail00 commented Oct 1, 2023

Describe your change:

Feature #9191

I have added a module to calculate energy equivalence by mass. Taking mass in kilograms and giving result in Joules.
the function names calculate_energy() which returns a floating value.

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • If this pull request resolves one or more open issues then the description above includes the issue number(s) with a closing keyword: "Fixes #ISSUE-NUMBER".

@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Oct 1, 2023
@algorithms-keeper algorithms-keeper bot added tests are failing Do not merge until tests pass and removed tests are failing Do not merge until tests pass labels Oct 1, 2023
@algorithms-keeper algorithms-keeper bot added tests are failing Do not merge until tests pass and removed tests are failing Do not merge until tests pass labels Oct 1, 2023
Copy link
Contributor

@CaedenPH CaedenPH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mhsuhail00 Maybe this should go in conversions/

Comment on lines 30 to 33
# Calculate energy using the equation E=mc^2
energy = mass * m.pow(speed_of_light, 2)
# return value has unit Joules
return energy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of having comments explain each line, please explain the equation and the input and output types in the function docstring

@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Oct 1, 2023
Copy link
Author

@mhsuhail00 mhsuhail00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have incorporated the suggestions made.

Copy link
Author

@mhsuhail00 mhsuhail00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have done the suggested changes.

@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Oct 1, 2023
Copy link
Author

@mhsuhail00 mhsuhail00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done all the suggested changes and passed the checks.

@algorithms-keeper algorithms-keeper bot added tests are failing Do not merge until tests pass and removed tests are failing Do not merge until tests pass labels Oct 1, 2023
Comment on lines +10 to +11
The function takes a single argument mass(in kg) having datatype float and
returns the energy(in joule) having datatype float
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a description of the function, so please put it in the function's docstring rather than the header string.

Comment on lines +5 to +8
Here it defines a Function to calculate energy(in joules) equivalent of a given
mass(in kilograms) using Einstein's Mass-energy equivalence equation E=mc^2
where m is mass and c = 299,792,458 meter per second is the speed of light
in vacuum (a constant value).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Here it defines a Function to calculate energy(in joules) equivalent of a given
mass(in kilograms) using Einstein's Mass-energy equivalence equation E=mc^2
where m is mass and c = 299,792,458 meter per second is the speed of light
in vacuum (a constant value).
This file defines a function to calculate energy (in joules) equivalent to a given
mass (in kilograms) using Einstein's mass-energy equivalence equation E=mc^2,
where m is mass and c = 299,792,458 m/s is the speed of light in a vacuum.

Fixes for grammar, formatting, and wording

@cclauss cclauss closed this Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting reviews This PR is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants